<?php

// 本类由系统自动生成，仅供测试用途
class BookdetailAction extends Action {

    public function index() {
        $userdetail = D('UserGoodsDetailView');
        $userdetailList = $userdetail->distinct(TRUE)->select();
        $this->assign('userdetaillist', $userdetailList);
        $this->display();
        
    }
    
     public function del() {
        $goodsdetail = M('goodsdetail');
        $where['userid'] = $_GET['userid'];
        var_dump($_GET['userid']);
        if ($goodsdetail->where($where)->delete()) {
            $this->success('删除成功');
            $this->redirect('Admin/Booklist/index');
        } else {
            $goodsdetail->getLastSql();
            $this->error('删除失败');
        }
    }

    public function submit_goods() {

        $goodsdetail = M('goodsdetail');
        if ($goodsdetail->create()) {
            //$brand = D('brand') ;
            if ($_POST['goodsid'] == NULL && $_POST['goodsnum'] == NULL) {
                $this->error('请填写订货数量');
            }

            $data['goodsnum'] = $_POST['goodsnum'];
            $data['goodsid'] = $_POST['goodsid'];
            $data["userid"] = $_SESSION['uid'];
            if ($goodsdetail->add($data)) {
                $this->success('数据添加成功！');
            } else {
                $this->error('数据写入错误');
            }
        } else {
            // 字段验证错误
            $this->error($goodsdetail->getError());
        }
    }

}